import {fromJS} from 'immutable'
import {RECEIVEHOMEDATA,RECEIVEMOREDATA,CHANGE_SHOW} from '../../../store/actionTypes'
//使用immutable来防止state数据被改变，
const defaultState = fromJS({
    topicList:[],
    contentList:[],
    recommendList:[],
    writingList:[],
    show:true,
});
export default (state = defaultState,action) =>{
   if(action.type == RECEIVEHOMEDATA){
        return state.set('topicList',action.topiclist).set('contentList',action.contentlist).set('recommendList',action.recommendlist).set('writingList',action.writinglist);
   }
   if(action.type == RECEIVEMOREDATA){
       return state.set('contentList',state.get('contentList').concat(action.data));
   }
   if(action.type == CHANGE_SHOW){
       return state.set('show',action.show);
   }
    return state;
}
